package com.stepshop.wechat.utils;

import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.stepshop.wechat.entity.MsgBase;
import com.stepshop.wechat.entity.MsgValueColor;

public class MsgSendUtil {
	public static void send(Map<String,MsgValueColor> data, String url, String temid, String openid) {
		HttpClientUtil httpClientUtil=new HttpClientUtil();
		MsgBase msg=new MsgBase();
		msg.setUrl(url);
		msg.setTemplate_id(temid);
		msg.setData(data);
		msg.setTouser(openid);
		String json = JSON.toJSONString(msg);
		System.out.println(json);
		String tokenJson=httpClientUtil.doPost("http://wechat-pre.0071515.com/pangu-wechat/dimenCode/getToken.do?valid=iiudihfeqpxkegEl4dkiR4SKd","","UTF-8");
		JSONObject tokenJSON = JSON.parseObject(tokenJson);
		Object token = tokenJSON.get("token");
//		String token="LA7tAlnp8D1sgnoButselthCO-QmrtUxk-irMDaPFd0vmKpOd1GcxbDUvADLL4XYiITkGfIHEK-8U0thSQct6EqRKzLvY9sOhOhyCMbLaSzOURYhFRswjOq3x4iBdfKAIPHeACADKC";
		String post = httpClientUtil.doPost("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token="+token,json, "UTF-8");
		System.out.println(post);
} 
	private MsgSendUtil(){
	}
}
